package com.spark.market.controller;

import com.spark.market.api.dto.PromoInfo;
import com.spark.market.api.utils.ResponseResult;
import com.spark.market.api.utils.ResponseUtil;
import com.spark.market.service.PromoQueryCoreService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/promo/query")
public class PromoQueryController extends BaseController{
    @Resource
    PromoQueryCoreService promoQueryCoreService;
    /**
     * 根据商品的id->秒杀详情(即将进行或者正在进行)
     */
    @GetMapping(value = "detail/{itemId}")
    public ResponseResult<PromoInfo> queryPromo(@PathVariable("itemId") Integer itemId){
        return ResponseUtil.createSuccessResult(promoQueryCoreService.queryPromoByItemId(itemId));
    }
}
